package com.example.demo.controller;

import com.alibaba.fastjson.JSON;
import com.example.demo.pojo.*;
import com.example.demo.service.PlayerService;
import com.example.demo.util.IdThreadLocal;
import com.example.demo.util.TokenUtil;
import io.minio.*;
import jdk.nashorn.internal.parser.Token;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import sun.nio.ch.IOUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
public class TestController {
    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;

    @Value("${kafka.topic.name}")
    private String topicName;


    @PostMapping("/log")
    public R test(@RequestBody Log data)  throws Exception{
        kafkaTemplate.send(topicName, JSON.toJSONString(data));
        System.out.println(JSON.toJSONString(data));
        return R.success("ok");
    }


}
